#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->progressBar->setMaximum(100);
    ui->progressBar->setMinimum(0);
    ui->progressBar->setValue(0);
    timer = new QTimer(this);
    connect(timer,&QTimer::timeout,this,&Widget::hendle);
    timer->start(100);
    ui->progressBar->setStyleSheet("QProgressBar::chunk{background-color:green;}");
    ui->progressBar->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter);

}

Widget::~Widget()
{
    delete ui;
}

void Widget::hendle()
{
    int value = ui->progressBar->value();
    if(value>=100)
    {
        timer->stop();
        return;
    }
    ui->progressBar->setValue(value+1);
    return;
}

